<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="10" :sm="12">
            <a-form-item label="支付日期" :labelCol="{span: 5}" :wrapperCol="{span: 18, offset: 1}">
              <j-date v-model="queryParam.payTime_begin" :showTime="false" date-format="YYYY-MM-DD HH:mm:ss" style="width:45%"
                placeholder="请选择开始时间"></j-date>
              <span style="width: 10px;">~</span>
              <j-date v-model="queryParam.payTime_end" :showTime="false" date-format="YYYY-MM-DD HH:mm:ss" style="width:45%"
                placeholder="请选择结束时间"></j-date>
            </a-form-item>
          </a-col>
          
          <template v-if="toggleSearchStatus">
            
          </template>
          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQueryCus" icon="search">查询</a-button>
              <a-button type="primary" @click="searchResetCus" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('订单')">导出</a-button>
      <!-- <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown> -->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <div class="data-toatl">
           <!-- <a-badge :count="orderTotal" :overflowCount="100000000">
             <a href="#" class="head-example">订单总数</a>
           </a-badge>
           <a-badge :count="saleAmountTotal" :overflowCount="100000000">
             <a href="#" class="head-example">销售总额</a>
           </a-badge>
           <a-badge :count="platAmountTotal" :overflowCount="100000000">
             <a href="#" class="head-example">收益总额</a>
           </a-badge> -->
           <a-tag color="#2db7f5">
             <p>订单总数:{{orderTotal}}</p>
           </a-tag>
           <a-tag color="pink">
             <p>销售总额:{{saleAmountTotal}}</p>
           </a-tag>
           <a-tag color="#87d068">
             <p>收益总额:{{platAmountTotal}}</p>
           </a-tag>
      </div>
      <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource" :pagination="ipagination"
        :loading="loading" :scroll="{ x: true }" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多
              <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

  </a-card>
</template>

<script>
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  import JDate from '@/components/jeecg/JDate'
  import { getToalSaleAmountData, listAllCorp, listAllOil } from '@/api/api'

  export default {
    name: "SaleDataList",
    mixins: [JeecgListMixin],
    components: {
      JDate
    },
    data() {
      return {
        description: '销售数据页面',
        orderTotal: 1,
        saleAmountTotal: 1,
        platAmountTotal: 1,
        // 表头
        columns: [{
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: "center",
            customRender: function(t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '日期',
            align: "center",
            width: 150,
            dataIndex: 'payTime'
          },
          {
            title: '订单数',
            align: "center",
            width: 120,
            dataIndex: 'orderTotal'
          },
          {
            title: '销售额',
            align: "center",
            width: 120,
            dataIndex: 'saleAmount'
          },
          {
            title: '平台收益',
            align: "center",
            width: 120,
            dataIndex: 'platAmount'
          },

        ],
        isorter:{
          column: 'payTime',
          order: 'desc',
        },
        url: {
          list: "/lww/order/listSaleAmountData",
          delete: "/lww/order/delete",
          deleteBatch: "/lww/order/deleteBatch",
          exportXlsUrl: "lww/order/exportXls",
          importExcelUrl: "lww/order/importExcel",
        },
      }
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    created() {
      
      this.getSaleAmountTotal();
    },
    methods: {
      getSaleAmountTotal(params) {
        let that = this;
        getToalSaleAmountData(params).then((res)=>{
          if(res.success){
            that.orderTotal = res.result.orderTotal;
            that.saleAmountTotal = res.result.saleAmount;
            that.platAmountTotal = res.result.platAmount;
          }
        }).finally(() => {
        })
      },
      searchQueryCus() {
        this.loadData(1);
        var params = this.getQueryParams();//查询条件
        this.getSaleAmountTotal(params);
      },
      searchResetCus() {
        this.queryParam = {}
        this.loadData(1);
        var params = this.getQueryParams();//查询条件
        this.getSaleAmountTotal(params);
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  .data-toatl {
    float: right;
    margin-bottom: 5px;
  }
  .head-example {
    width:120px;
    height: 40px;
    display:inline-block;
    text-align: center;
    line-height: 40px;
    margin: 5px 10px;
    border:1px solid #eee;
  }
</style>
